package cn.wx.jove.core.service;


import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.wx.jove.core.entity.Plate;
import cn.wx.common.persistence.base.BaseService;
import cn.wx.jove.core.mapper.PlateMapper;
import cn.wx.common.persistence.exception.MyException;
import cn.wx.common.persistence.web.ResponseCode;


/**
 * <p>
 * 板块表 服务类
 * </p>
 *
 * @author  
 * @since 2018-11-30
 */
@Service
@Transactional
public class PlateService extends BaseService<Plate, PlateMapper> {

	/**
	 * 新增板块表
	 * @param plate
	 * @return
	 * @throws MyException 
	 */
	 public boolean create(Plate plate) throws MyException{
	 	return insert(plate);
	 }
	 
	 /**
	 * 修改板块表
	 * @param plate
	 * @return
	 * @throws MyException 
	 */
	public boolean modify(Plate plate) throws MyException{
		// PID 不能为空
		if (plate.getpId() == null) {
			throw new MyException(ResponseCode.PARAMETER_REQUIRED);
		}
		return update(plate);
	}
	
	/**
	 * 删除板块表
	 * @param plate
	 * @return
	 * @throws MyException 
	 */
	public boolean remove(Plate plate) throws MyException{
		// PID 不能为空
		if (plate.getpId() == null) {
			throw new MyException(ResponseCode.PARAMETER_REQUIRED);
		}
		plate.setfRemove(true);
		return update(plate);
	}
}
